import React, { Component } from 'react';
import { Card, Button, Form, Input, Space } from 'antd';
import './login.less';
import { withRouter } from 'umi';
import { addCanvas } from '@/hoc/index.js';
import {userLogin} from "@/api/login"
import  * as _ from 'lodash';
function Login(props: any) {
  const { history } = props;
  const onFinish = (values: any) => {
    console.log('Success:', values);
    userLogin(values).then(res=>{
      console.log(res);
      
    })
    localStorage.setItem('token', '200');
    history.push('/index/Wq');
  };

  const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
  };
  return (
    <div className="bb">
      <Card
        title="管理中心登陆"
        className="aa"
        headStyle={{ textAlign: 'center', fontSize: 23, fontWeight: 3000 }}
      >
        <Form
          name="basic"
          initialValues={{ remember: true }}
          onFinish={_.debounce(onFinish,2000) }
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            label="账号"
            name="username"
            rules={[{ required: true, message: '请输入你的账号!' }]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            label="密码"
            name="password"
            rules={[{ required: true, message: '请输入你的密码!' }]}
          >
            <Input.Password />
          </Form.Item>
          <Form.Item
            label="验证码"
            name="verify_code"
            rules={[{ required: true, message: '请输入验证码!' }]}
          >
            <Space>
              <Input />
              <Button>
                <img
                  src="http://fangadmin.shbwyz.com/login/verfiy.html?t=1677240940893"
                  alt=""
                  style={{ width: '100%', height: '100%' }}
                />
              </Button>
            </Space>
          </Form.Item>

          <Form.Item style={{ width: '100%' ,marginLeft:150}}>
            <Button type="primary" htmlType="submit">
              登陆
            </Button>
          </Form.Item>
        </Form>
      </Card>
    </div>
  );
}
export default addCanvas(withRouter(Login));
